
//
//  WIFIHelper.m
//  Router
//
//  Created by teki on 15/10/22.
//  Copyright © 2015年 dc. All rights reserved.
//

#import "WIFIHelper.h"

@implementation WIFIHelper

- (void)getUpLoadAnDownLoadSpeedWithDeviceID:(NSString *)device_id success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"deviceID":device_id};
    [self.requestOperator requestPostWithURL:WIFI_UPLOAD_AND_DOWNLOAD_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(YES,responseObject,nil);
    } failure:failure];

}


- (void)refreshDataWithDeviceID:(NSString *)device_id userName:(NSString *)userName success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"deviceID":device_id,
                            @"user":userName};
    [self.requestOperator requestPostWithURL:WIFI_REFRESH_DATA_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}


- (void)settingWIFIInfoWithSSID:(NSString *)ssid password:(NSString *)password deviceID:(NSString *)device_id success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"SSID":ssid,
                            @"pwd":password,
                            @"deviceID":device_id};
    [self.requestOperator requestPostWithURL:WIFI_SETTING_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}



- (void)settingWIFIStatusWithDeviceID:(NSString *)device_id switchStatus:(BOOL)isOpen power:(NSInteger)power masterDeviceID:(NSString *)masterDevice_id success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"deviceID":device_id,
                            @"switchStatus":[NSString stringWithFormat:@"%d",!isOpen],
                            @"power":@(power),
                            @"masterDeviceID":masterDevice_id};
    NSLog(@"settingWIFIStatus:%@",param);
    [self.requestOperator requestPostWithURL:WIFI_SETTING_OPEN_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}




- (void)settingWIFIHealthModelWithDeviceID:(NSString *)deviceID wifi_on_time:(NSString *)wifiOnTime wifi_off_time:(NSString *)wifiOffTime enable:(BOOL)enable masterDeviceID:(NSString *)masterDeviceID success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"deviceID":deviceID,
                            @"wifi_on_time":wifiOnTime,
                            @"wifi_off_time":wifiOffTime,
                            @"enable":@(enable),
                            @"masterDeviceID":masterDeviceID};
    [self.requestOperator requestPostWithURL:WIFI_SETTING_TIME_STATUS_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}



- (void)setDeviceAliasWithAlias:(NSString *)alias deviceID:(NSString *)deviceID masterDeviceID:(NSString *)masterDeviceID success:(RequestSussess)success failure:(RequestFailure)failure
{
    NSDictionary *param = @{@"deviceID":deviceID,
                            @"alias":alias,
                            @"masterDeviceID":masterDeviceID};
    [self.requestOperator requestPostWithURL:WIFI_SETTING_ALIAS_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}


- (void)checkUpdateWithDeviceID:(NSString *)deviceid masterDeviceID:(NSString *)masterDeviceID success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];
    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceid,@"masterDeviceID":masterDeviceID};
    [self.requestOperator requestPostWithURL:WIFI_CHECK_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}





- (void)upgradeMotherCatWithDeviceID:(NSString *)deviceID fileURL:(NSString *)fileURL success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];
    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceID,@"file_url":fileURL};
    [self.requestOperator requestPostWithURL:WIFI_MOTHERCAT_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}



- (void)upgradeSonCatWithDeviceID:(NSString *)deviceID masterDeviceID:(NSString *)masterDeviceID fileURL:(NSString *)fileURL success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];

    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceID,@"masterDeviceID":masterDeviceID,@"file_url":fileURL};
    [self.requestOperator requestPostWithURL:WIFI_SONCAT_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}




- (RequestManager *)getCheckUpdateWithDeviceID:(NSString *)deviceid masterDeviceID:(NSString *)masterDeviceID success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];
    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceid,@"masterDeviceID":masterDeviceID};
    
    return [self.requestOperator getOperationPostWithUrl:WIFI_CHECK_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}

- (RequestManager *)getUpgradeMotherCatWithDeviceID:(NSString *)deviceID fileURL:(NSString *)fileURL success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];
    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceID,@"file_url":fileURL};
    return [self.requestOperator getOperationPostWithUrl:WIFI_MOTHERCAT_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];
}

- (RequestManager *)getUpgradeSonCatWithDeviceID:(NSString *)deviceID masterDeviceID:(NSString *)masterDeviceID fileURL:(NSString *)fileURL success:(RequestSussess)success failure:(RequestFailure)failure
{
    UserModel *user = [UserSingleton shareInstance].userModel.user[0];
    
    NSDictionary *param = @{@"user":user.userName,@"deviceID":deviceID,@"masterDeviceID":masterDeviceID,@"file_url":fileURL};
    return [self.requestOperator getOperationPostWithUrl:WIFI_SONCAT_UPDATE_POST_URL params:param success:^(BOOL succ, id responseObject) {
        success(succ,responseObject,nil);
    } failure:failure];

}




@end
